package com.jixiaotian.spring.annotation.demo.annotation.componentscan;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.Arrays;
import java.util.Random;

/**
 * @Author: jixiaotian.ch@qq.com
 * @Date : 2020/9/10
 */
public class MyTest {

    private int[] colorCode = {30,31,32,33,34,35,36,37,90,91,92,93,94,95,96,97};
    private void out(String str){
        System.out.println("\033[" + String.valueOf(colorCode[new Random().nextInt(colorCode.length)])+";1m"+str+"\033[0m");
    }

    @Test
    public void test() {

        ApplicationContext app = new AnnotationConfigApplicationContext(MyConfig.class);
        String[] beanNames = app.getBeanDefinitionNames();
        out("beanName:" + Arrays.toString(beanNames));
        out(Arrays.toString(beanNames)
                .replaceAll("\\[|\\]", "")
                .replaceAll(" ","")
                .replaceAll(",", "\n"));
    }

    @Test
    public void test1() {

        for(int i=0;i<100;i++) {

            System.out.println("\033["+String.valueOf(i)+"m i~~"+i+"\033[0m");


        }


    }

}
